/******************************************************************************
  YFLineFollow.h
  YFROBOT Line Follow Sensor Library Source File
  Creation Date: 01-18-2022
  @ YFROBOT

  Distributed as-is; no warranty is given.
******************************************************************************/

#include "YFLINEFOLLOW.h"

YFLINEFOLLOW::YFLINEFOLLOW(uint8_t address) {}

//初始化传感器
uint8_t YFLINEFOLLOW::begin(uint8_t address) {
  Wire.begin();
  return  _sx1508.begin(address);
}

//读取传感器值
// numSensor : 0 1 2 3 4  ; 5路巡线传感器
uint8_t YFLINEFOLLOW::readSensor(uint8_t numSensor) {
  return !_sx1508.digitalRead(numSensor);
}

//禁用传感器
void YFLINEFOLLOW::disableSensor() {
  _sx1508.pinMode(LINESENSOREN, OUTPUT);
  _sx1508.digitalWrite(LINESENSOREN, LOW);
}

//使能传感器
void YFLINEFOLLOW::enableSensor() {
  _sx1508.pinMode(LINESENSOREN, OUTPUT);
  _sx1508.digitalWrite(LINESENSOREN, HIGH);
}


